package com.bjtang.book.interceptor;

import javax.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 

/**
 * @ClassName: WebConfig
 * @Description:
 * @author weiyb
 * @date 2018年5月7日 上午11:30:58
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
	@Resource
	private LoginInterceptor loginInterceptor;
 
	 @Override
	    public void addInterceptors(InterceptorRegistry registry) {
	  //      InterceptorRegistration addInterceptor = registry.addInterceptor(loginInterceptor);
	        // 排除配置
	  //      addInterceptor.excludePathPatterns("/static/**");//排除静态资源
	   //     addInterceptor.excludePathPatterns("/login/**");
	        // 拦截配置
	   //     addInterceptor.addPathPatterns("/**");
	//	 registry.addInterceptor(loginInterceptor).excludePathPatterns(Arrays.asList("/**")).addPathPatterns("/**");
		 
		 registry.addInterceptor(loginInterceptor)
		 // 放行文件
		 .addPathPatterns("/**").excludePathPatterns("/*.*");
		// .addPathPatterns("/**").excludePathPatterns("/static/**");
	    }
	 
	//配置静态资源的位置
	 //这里的addResourceLocations可以把文件映射到本地的绝对路径
	    @Override
	    public void addResourceHandlers(ResourceHandlerRegistry registry) {
	    	
	    	
	    }
}